package com.fzj.charging.order.controller;

import com.fzj.charging.common.pojo.JsonResult;
import com.fzj.charging.order.pojo.dto.OrderAddParam;
import com.fzj.charging.order.service.OrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RequestMapping("/order")
@RestController
@Slf4j
@Api(tags = "订单接口")
public class OrderController {
    @Autowired
    private OrderService orderService;

    @PostMapping("createOrder")
    @ApiOperation("创建订单")
    public JsonResult<String> createOrder(@RequestBody OrderAddParam orderAddParam){
        log.debug("创建订单,参数：{}",orderAddParam);
        log.debug("创建订单,调用createOrder,参数：{}",orderAddParam);
        String orderNo = orderService.createOrder(orderAddParam);
        log.debug("创建订单,调用createOrder,参数：{},结果：{}",orderAddParam,orderNo);
        JsonResult<String> result = JsonResult.ok(orderNo, "创建订单成功");
        log.debug("创建订单,参数：{},结果：{}",orderAddParam,result);
        return result;
    }

}
